
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 05/21/2014 15:38:56
-- Generated from EDMX file: C:\Users\LucasAndres\Desktop\Repositoriodesarrollo2\UricaoWeb\Datos\UricaoER.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [UricaoBD];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_HotelHot_Tou]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hot_Tou] DROP CONSTRAINT [FK_HotelHot_Tou];
GO
IF OBJECT_ID(N'[dbo].[FK_Hot_TouTour]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hot_Tou] DROP CONSTRAINT [FK_Hot_TouTour];
GO
IF OBJECT_ID(N'[dbo].[FK_HotelPiso]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Piso] DROP CONSTRAINT [FK_HotelPiso];
GO
IF OBJECT_ID(N'[dbo].[FK_HotelRestaurante]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Restaurante] DROP CONSTRAINT [FK_HotelRestaurante];
GO
IF OBJECT_ID(N'[dbo].[FK_MenuMen_Pla]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Men_Pla] DROP CONSTRAINT [FK_MenuMen_Pla];
GO
IF OBJECT_ID(N'[dbo].[FK_PlatoMen_Pla]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Men_Pla] DROP CONSTRAINT [FK_PlatoMen_Pla];
GO
IF OBJECT_ID(N'[dbo].[FK_HotelEmpleado]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Empleado] DROP CONSTRAINT [FK_HotelEmpleado];
GO
IF OBJECT_ID(N'[dbo].[FK_ReservacionTou_Res]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Tou_Res] DROP CONSTRAINT [FK_ReservacionTou_Res];
GO
IF OBJECT_ID(N'[dbo].[FK_Tou_ResTour]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Tou_Res] DROP CONSTRAINT [FK_Tou_ResTour];
GO
IF OBJECT_ID(N'[dbo].[FK_CargoEmpleado]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Empleado] DROP CONSTRAINT [FK_CargoEmpleado];
GO
IF OBJECT_ID(N'[dbo].[FK_Hab_EmpEmpleado]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hab_Emp] DROP CONSTRAINT [FK_Hab_EmpEmpleado];
GO
IF OBJECT_ID(N'[dbo].[FK_ReservacionCliente]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Reservacion] DROP CONSTRAINT [FK_ReservacionCliente];
GO
IF OBJECT_ID(N'[dbo].[FK_Hab_ResReservacion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hab_Res] DROP CONSTRAINT [FK_Hab_ResReservacion];
GO
IF OBJECT_ID(N'[dbo].[FK_ReservacionMes_Res]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Mes_Res] DROP CONSTRAINT [FK_ReservacionMes_Res];
GO
IF OBJECT_ID(N'[dbo].[FK_Mes_ResMesa]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Mes_Res] DROP CONSTRAINT [FK_Mes_ResMesa];
GO
IF OBJECT_ID(N'[dbo].[FK_RestauranteMenu]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [FK_RestauranteMenu];
GO
IF OBJECT_ID(N'[dbo].[FK_PlatoMes_Res]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Mes_Res] DROP CONSTRAINT [FK_PlatoMes_Res];
GO
IF OBJECT_ID(N'[dbo].[FK_PlatoRoomService]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RoomService] DROP CONSTRAINT [FK_PlatoRoomService];
GO
IF OBJECT_ID(N'[dbo].[FK_RoomServiceReservacion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RoomService] DROP CONSTRAINT [FK_RoomServiceReservacion];
GO
IF OBJECT_ID(N'[dbo].[FK_RestauranteMesa]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Mesa] DROP CONSTRAINT [FK_RestauranteMesa];
GO
IF OBJECT_ID(N'[dbo].[FK_UsuarioEmpleado]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Usuario] DROP CONSTRAINT [FK_UsuarioEmpleado];
GO
IF OBJECT_ID(N'[dbo].[FK_HorarioTour]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Horario] DROP CONSTRAINT [FK_HorarioTour];
GO
IF OBJECT_ID(N'[dbo].[FK_PisoHabitacion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Habitacion] DROP CONSTRAINT [FK_PisoHabitacion];
GO
IF OBJECT_ID(N'[dbo].[FK_Hab_ResHabitacion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hab_Res] DROP CONSTRAINT [FK_Hab_ResHabitacion];
GO
IF OBJECT_ID(N'[dbo].[FK_Hab_EmpHabitacion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hab_Emp] DROP CONSTRAINT [FK_Hab_EmpHabitacion];
GO
IF OBJECT_ID(N'[dbo].[FK_PropiedadHotel]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Propiedad] DROP CONSTRAINT [FK_PropiedadHotel];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Hotel]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hotel];
GO
IF OBJECT_ID(N'[dbo].[Habitacion]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Habitacion];
GO
IF OBJECT_ID(N'[dbo].[Tour]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Tour];
GO
IF OBJECT_ID(N'[dbo].[Restaurante]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Restaurante];
GO
IF OBJECT_ID(N'[dbo].[Menu]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Menu];
GO
IF OBJECT_ID(N'[dbo].[Plato]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Plato];
GO
IF OBJECT_ID(N'[dbo].[Reservacion]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Reservacion];
GO
IF OBJECT_ID(N'[dbo].[Usuario]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Usuario];
GO
IF OBJECT_ID(N'[dbo].[Empleado]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Empleado];
GO
IF OBJECT_ID(N'[dbo].[Cliente]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Cliente];
GO
IF OBJECT_ID(N'[dbo].[Cargo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Cargo];
GO
IF OBJECT_ID(N'[dbo].[Piso]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Piso];
GO
IF OBJECT_ID(N'[dbo].[Mesa]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Mesa];
GO
IF OBJECT_ID(N'[dbo].[RoomService]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RoomService];
GO
IF OBJECT_ID(N'[dbo].[Hot_Tou]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hot_Tou];
GO
IF OBJECT_ID(N'[dbo].[Hab_Res]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hab_Res];
GO
IF OBJECT_ID(N'[dbo].[Hab_Emp]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hab_Emp];
GO
IF OBJECT_ID(N'[dbo].[Tou_Res]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Tou_Res];
GO
IF OBJECT_ID(N'[dbo].[Mes_Res]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Mes_Res];
GO
IF OBJECT_ID(N'[dbo].[Men_Pla]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Men_Pla];
GO
IF OBJECT_ID(N'[dbo].[Horario]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Horario];
GO
IF OBJECT_ID(N'[dbo].[Propiedad]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Propiedad];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Hotel'
CREATE TABLE [dbo].[Hotel] (
    [IdHotel] int IDENTITY(1,1) NOT NULL,
    [nombreHotel] nvarchar(max)  NOT NULL,
    [descripcionHotel] nvarchar(max)  NOT NULL,
    [telefonoHotel] bigint  NOT NULL,
    [estrellaHotel] nchar(1)  NOT NULL,
    [direccionHotel] nvarchar(max)  NOT NULL,
    [fotoHotel] nvarchar(max)  NOT NULL,
    [monedaHotel] nvarchar(max)  NOT NULL,
    [activoHotel] bit  NOT NULL
);
GO

-- Creating table 'Habitacion'
CREATE TABLE [dbo].[Habitacion] (
    [IdHabitacion] int IDENTITY(1,1) NOT NULL,
    [fkPiso] int  NOT NULL,
    [fkHotel] int  NOT NULL,
    [tipoHabitacion] nvarchar(max)  NOT NULL,
    [disponibilidadHabitacion] bit  NOT NULL,
    [montoHabitacion] float  NOT NULL,
    [capacidadHabitacion] smallint  NOT NULL,
    [numeroHabitacion] smallint  NOT NULL,
    [descripcionHabitacion] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Tour'
CREATE TABLE [dbo].[Tour] (
    [IdTour] int IDENTITY(1,1) NOT NULL,
    [descripcionTour] nvarchar(max)  NOT NULL,
    [precioTour] float  NOT NULL,
    [capacidadTour] smallint  NOT NULL,
    [nombreTour] nvarchar(max)  NOT NULL,
    [activoTour] bit  NOT NULL
);
GO

-- Creating table 'Restaurante'
CREATE TABLE [dbo].[Restaurante] (
    [IdRestaurante] int IDENTITY(1,1) NOT NULL,
    [nombreRestaurante] nvarchar(max)  NOT NULL,
    [telefonoRestaurante] nvarchar(max)  NOT NULL,
    [tipoRestaurante] nvarchar(max)  NOT NULL,
    [capacidadRestaurante] smallint  NOT NULL,
    [aperturaRestaurante] datetime  NOT NULL,
    [clausuraRestaurante] datetime  NULL,
    [activoRestaurante] bit  NOT NULL,
    [fkHotel] int  NOT NULL
);
GO

-- Creating table 'Menu'
CREATE TABLE [dbo].[Menu] (
    [IdMenu] int IDENTITY(1,1) NOT NULL,
    [nombreMenu] nvarchar(max)  NOT NULL,
    [tipoMenu] nvarchar(max)  NOT NULL,
    [activoMenu] bit  NOT NULL,
    [fkRestaurante] int  NOT NULL
);
GO

-- Creating table 'Plato'
CREATE TABLE [dbo].[Plato] (
    [IdPlato] int IDENTITY(1,1) NOT NULL,
    [nombrePlato] nvarchar(max)  NOT NULL,
    [precioPlato] float  NOT NULL,
    [fotoPlato] nvarchar(max)  NOT NULL,
    [detallePlato] nvarchar(max)  NOT NULL,
    [compartirPlato] bit  NOT NULL,
    [activoPlato] bit  NOT NULL
);
GO

-- Creating table 'Reservacion'
CREATE TABLE [dbo].[Reservacion] (
    [IdReservacion] int IDENTITY(1,1) NOT NULL,
    [salidaReservacion] datetime  NOT NULL,
    [llegadaReservacion] datetime  NOT NULL,
    [codigoReservacion] nvarchar(max)  NOT NULL,
    [estatusReservacion] nvarchar(max)  NOT NULL,
    [fkCliente] int  NOT NULL
);
GO

-- Creating table 'Usuario'
CREATE TABLE [dbo].[Usuario] (
    [IdUsuario] int IDENTITY(1,1) NOT NULL,
    [nombreUsuario] nvarchar(max)  NOT NULL,
    [claveUsuario] nvarchar(max)  NOT NULL,
    [fkEmpleado] int  NOT NULL
);
GO

-- Creating table 'Empleado'
CREATE TABLE [dbo].[Empleado] (
    [IdEmpleado] int IDENTITY(1,1) NOT NULL,
    [nombreEmpleado] nvarchar(max)  NOT NULL,
    [apellidoEmpleado] nvarchar(max)  NOT NULL,
    [nacimientoEmpleado] datetime  NOT NULL,
    [direccionEmpleado] nvarchar(max)  NOT NULL,
    [activoEmpleado] bit  NOT NULL,
    [correoEmpleado] nvarchar(max)  NULL,
    [fkHotel] int  NOT NULL,
    [fkCargo] int  NOT NULL
);
GO

-- Creating table 'Cliente'
CREATE TABLE [dbo].[Cliente] (
    [IdCliente] int IDENTITY(1,1) NOT NULL,
    [nombreCliente] nvarchar(max)  NOT NULL,
    [apellidoCliente] nvarchar(max)  NOT NULL,
    [documentoCliente] nvarchar(max)  NOT NULL,
    [tarjetaCliente] nvarchar(max)  NOT NULL,
    [tipoDocCliente] nvarchar(max)  NOT NULL,
    [correoCliente] nvarchar(max)  NULL
);
GO

-- Creating table 'Cargo'
CREATE TABLE [dbo].[Cargo] (
    [IdCargo] int IDENTITY(1,1) NOT NULL,
    [nombreCargo] nvarchar(max)  NOT NULL,
    [activoCargo] bit  NOT NULL
);
GO

-- Creating table 'Piso'
CREATE TABLE [dbo].[Piso] (
    [IdPiso] int IDENTITY(1,1) NOT NULL,
    [fkHotel] int  NOT NULL,
    [numeroPiso] nchar(2)  NOT NULL
);
GO

-- Creating table 'Mesa'
CREATE TABLE [dbo].[Mesa] (
    [IdMesa] int IDENTITY(1,1) NOT NULL,
    [capacidadMesa] smallint  NOT NULL,
    [fkRestaurante] int  NOT NULL
);
GO

-- Creating table 'RoomService'
CREATE TABLE [dbo].[RoomService] (
    [IdRoomService] int IDENTITY(1,1) NOT NULL,
    [fkPlato] int  NOT NULL,
    [fkReservacion] int  NOT NULL,
	[horaRoom] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Hot_Tou'
CREATE TABLE [dbo].[Hot_Tou] (
    [fkHotel] int  NOT NULL,
    [fkTour] int  NOT NULL
);
GO

-- Creating table 'Hab_Res'
CREATE TABLE [dbo].[Hab_Res] (
    [fkReservacion] int  NOT NULL,
    [checkinHabitacion] bit  NULL,
    [checkoutHabitacion] bit  NULL,
    [adultoHabitacion] smallint  NOT NULL,
    [ninoHabitacion] smallint  NULL,
    [fkHabitacion] int  NOT NULL,
    [fkPiso] int  NOT NULL,
    [fkHotel] int  NOT NULL
);
GO

-- Creating table 'Hab_Emp'
CREATE TABLE [dbo].[Hab_Emp] (
    [fkEmpleado] int  NOT NULL,
    [horaLimpieza] datetime  NOT NULL,
    [fkHabitacion] int  NOT NULL,
    [fkPiso] int  NOT NULL,
    [fkHotel] int  NOT NULL
);
GO

-- Creating table 'Tou_Res'
CREATE TABLE [dbo].[Tou_Res] (
    [idTou_Res] int IDENTITY(1,1)  NOT NULL,
    [fechaReserva] datetime  NOT NULL,
    [personasReserva] smallint  NOT NULL,
    [precioTotal] float  NOT NULL,
    [fkReservacion] int  NOT NULL,
    [fkTour] int  NOT NULL
);
GO

-- Creating table 'Mes_Res'
CREATE TABLE [dbo].[Mes_Res] (
    [idMes_Res] int IDENTITY(1,1)  NOT NULL,
    [fechaEntrada] datetime  NOT NULL,
    [cantidadPersonas] smallint  NOT NULL,
    [fkReservacion] int  NOT NULL,
    [fkMesa] int  NOT NULL,
    [fkPlato] int  NULL
);
GO

-- Creating table 'Men_Pla'
CREATE TABLE [dbo].[Men_Pla] (
    [fkMenu] int  NOT NULL,
    [fkPlato] int  NOT NULL
);
GO

-- Creating table 'Horario'
CREATE TABLE [dbo].[Horario] (
    [IdHorario] int IDENTITY(1,1) NOT NULL,
    [horaInicioHorario] datetime  NOT NULL,
    [horaFinHorario] datetime  NOT NULL,
    [diaHorario] nvarchar(max)  NOT NULL,
    [fkTour] int  NOT NULL
);
GO

-- Creating table 'Propiedad'
CREATE TABLE [dbo].[Propiedad] (
    [IdPropiedad] int IDENTITY(1,1) NOT NULL,
    [fkHotel] int  NOT NULL,
    [nombrePropiedad] nvarchar(max)  NOT NULL,
    [tipoPropiedad] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [IdHotel] in table 'Hotel'
ALTER TABLE [dbo].[Hotel]
ADD CONSTRAINT [PK_Hotel]
    PRIMARY KEY CLUSTERED ([IdHotel] ASC);
GO

-- Creating primary key on [IdHabitacion], [fkPiso], [fkHotel] in table 'Habitacion'
ALTER TABLE [dbo].[Habitacion]
ADD CONSTRAINT [PK_Habitacion]
    PRIMARY KEY CLUSTERED ([IdHabitacion], [fkPiso], [fkHotel] ASC);
GO

-- Creating primary key on [IdTour] in table 'Tour'
ALTER TABLE [dbo].[Tour]
ADD CONSTRAINT [PK_Tour]
    PRIMARY KEY CLUSTERED ([IdTour] ASC);
GO

-- Creating primary key on [IdRestaurante] in table 'Restaurante'
ALTER TABLE [dbo].[Restaurante]
ADD CONSTRAINT [PK_Restaurante]
    PRIMARY KEY CLUSTERED ([IdRestaurante] ASC);
GO

-- Creating primary key on [IdMenu] in table 'Menu'
ALTER TABLE [dbo].[Menu]
ADD CONSTRAINT [PK_Menu]
    PRIMARY KEY CLUSTERED ([IdMenu] ASC);
GO

-- Creating primary key on [IdPlato] in table 'Plato'
ALTER TABLE [dbo].[Plato]
ADD CONSTRAINT [PK_Plato]
    PRIMARY KEY CLUSTERED ([IdPlato] ASC);
GO

-- Creating primary key on [IdReservacion] in table 'Reservacion'
ALTER TABLE [dbo].[Reservacion]
ADD CONSTRAINT [PK_Reservacion]
    PRIMARY KEY CLUSTERED ([IdReservacion] ASC);
GO

-- Creating primary key on [IdUsuario] in table 'Usuario'
ALTER TABLE [dbo].[Usuario]
ADD CONSTRAINT [PK_Usuario]
    PRIMARY KEY CLUSTERED ([IdUsuario] ASC);
GO

-- Creating primary key on [IdEmpleado] in table 'Empleado'
ALTER TABLE [dbo].[Empleado]
ADD CONSTRAINT [PK_Empleado]
    PRIMARY KEY CLUSTERED ([IdEmpleado] ASC);
GO

-- Creating primary key on [IdCliente] in table 'Cliente'
ALTER TABLE [dbo].[Cliente]
ADD CONSTRAINT [PK_Cliente]
    PRIMARY KEY CLUSTERED ([IdCliente] ASC);
GO

-- Creating primary key on [IdCargo] in table 'Cargo'
ALTER TABLE [dbo].[Cargo]
ADD CONSTRAINT [PK_Cargo]
    PRIMARY KEY CLUSTERED ([IdCargo] ASC);
GO

-- Creating primary key on [IdPiso], [fkHotel] in table 'Piso'
ALTER TABLE [dbo].[Piso]
ADD CONSTRAINT [PK_Piso]
    PRIMARY KEY CLUSTERED ([IdPiso], [fkHotel] ASC);
GO

-- Creating primary key on [IdMesa] in table 'Mesa'
ALTER TABLE [dbo].[Mesa]
ADD CONSTRAINT [PK_Mesa]
    PRIMARY KEY CLUSTERED ([IdMesa] ASC);
GO

-- Creating primary key on [IdRoomService], [fkPlato], [fkReservacion] in table 'RoomService'
ALTER TABLE [dbo].[RoomService]
ADD CONSTRAINT [PK_RoomService]
    PRIMARY KEY CLUSTERED ([IdRoomService], [fkPlato], [fkReservacion] ASC);
GO

-- Creating primary key on [fkTour], [fkHotel] in table 'Hot_Tou'
ALTER TABLE [dbo].[Hot_Tou]
ADD CONSTRAINT [PK_Hot_Tou]
    PRIMARY KEY NONCLUSTERED ([fkTour], [fkHotel] ASC);
GO

-- Creating primary key on [fkReservacion], [fkPiso], [fkHotel], [fkHabitacion] in table 'Hab_Res'
ALTER TABLE [dbo].[Hab_Res]
ADD CONSTRAINT [PK_Hab_Res]
    PRIMARY KEY CLUSTERED ([fkReservacion], [fkPiso], [fkHotel], [fkHabitacion] ASC);
GO

-- Creating primary key on [fkEmpleado], [horaLimpieza], [fkHabitacion], [fkPiso], [fkHotel] in table 'Hab_Emp'
ALTER TABLE [dbo].[Hab_Emp]
ADD CONSTRAINT [PK_Hab_Emp]
    PRIMARY KEY CLUSTERED ([fkEmpleado], [horaLimpieza], [fkHabitacion], [fkPiso], [fkHotel] ASC);
GO

-- Creating primary key on [idTou_Res] in table 'Tou_Res'
ALTER TABLE [dbo].[Tou_Res]
ADD CONSTRAINT [PK_Tou_Res]
    PRIMARY KEY CLUSTERED ([idTou_Res] ASC);
GO

-- Creating primary key on [idMes_Res] in table 'Mes_Res'
ALTER TABLE [dbo].[Mes_Res]
ADD CONSTRAINT [PK_Mes_Res]
    PRIMARY KEY CLUSTERED ([idMes_Res] ASC);
GO

-- Creating primary key on [fkMenu], [fkPlato] in table 'Men_Pla'
ALTER TABLE [dbo].[Men_Pla]
ADD CONSTRAINT [PK_Men_Pla]
    PRIMARY KEY NONCLUSTERED ([fkMenu], [fkPlato] ASC);
GO

-- Creating primary key on [IdHorario] in table 'Horario'
ALTER TABLE [dbo].[Horario]
ADD CONSTRAINT [PK_Horario]
    PRIMARY KEY CLUSTERED ([IdHorario] ASC);
GO

-- Creating primary key on [IdPropiedad], [fkHotel] in table 'Propiedad'
ALTER TABLE [dbo].[Propiedad]
ADD CONSTRAINT [PK_Propiedad]
    PRIMARY KEY CLUSTERED ([IdPropiedad], [fkHotel] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [fkHotel] in table 'Hot_Tou'
ALTER TABLE [dbo].[Hot_Tou]
ADD CONSTRAINT [FK_HotelHot_Tou]
    FOREIGN KEY ([fkHotel])
    REFERENCES [dbo].[Hotel]
        ([IdHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HotelHot_Tou'
CREATE INDEX [IX_FK_HotelHot_Tou]
ON [dbo].[Hot_Tou]
    ([fkHotel]);
GO

-- Creating foreign key on [fkTour] in table 'Hot_Tou'
ALTER TABLE [dbo].[Hot_Tou]
ADD CONSTRAINT [FK_Hot_TouTour]
    FOREIGN KEY ([fkTour])
    REFERENCES [dbo].[Tour]
        ([IdTour])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [fkHotel] in table 'Piso'
ALTER TABLE [dbo].[Piso]
ADD CONSTRAINT [FK_HotelPiso]
    FOREIGN KEY ([fkHotel])
    REFERENCES [dbo].[Hotel]
        ([IdHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HotelPiso'
CREATE INDEX [IX_FK_HotelPiso]
ON [dbo].[Piso]
    ([fkHotel]);
GO

-- Creating foreign key on [fkHotel] in table 'Restaurante'
ALTER TABLE [dbo].[Restaurante]
ADD CONSTRAINT [FK_HotelRestaurante]
    FOREIGN KEY ([fkHotel])
    REFERENCES [dbo].[Hotel]
        ([IdHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HotelRestaurante'
CREATE INDEX [IX_FK_HotelRestaurante]
ON [dbo].[Restaurante]
    ([fkHotel]);
GO

-- Creating foreign key on [fkMenu] in table 'Men_Pla'
ALTER TABLE [dbo].[Men_Pla]
ADD CONSTRAINT [FK_MenuMen_Pla]
    FOREIGN KEY ([fkMenu])
    REFERENCES [dbo].[Menu]
        ([IdMenu])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [fkPlato] in table 'Men_Pla'
ALTER TABLE [dbo].[Men_Pla]
ADD CONSTRAINT [FK_PlatoMen_Pla]
    FOREIGN KEY ([fkPlato])
    REFERENCES [dbo].[Plato]
        ([IdPlato])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PlatoMen_Pla'
CREATE INDEX [IX_FK_PlatoMen_Pla]
ON [dbo].[Men_Pla]
    ([fkPlato]);
GO

-- Creating foreign key on [fkHotel] in table 'Empleado'
ALTER TABLE [dbo].[Empleado]
ADD CONSTRAINT [FK_HotelEmpleado]
    FOREIGN KEY ([fkHotel])
    REFERENCES [dbo].[Hotel]
        ([IdHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HotelEmpleado'
CREATE INDEX [IX_FK_HotelEmpleado]
ON [dbo].[Empleado]
    ([fkHotel]);
GO

-- Creating foreign key on [fkReservacion] in table 'Tou_Res'
ALTER TABLE [dbo].[Tou_Res]
ADD CONSTRAINT [FK_ReservacionTou_Res]
    FOREIGN KEY ([fkReservacion])
    REFERENCES [dbo].[Reservacion]
        ([IdReservacion])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ReservacionTou_Res'
CREATE INDEX [IX_FK_ReservacionTou_Res]
ON [dbo].[Tou_Res]
    ([fkReservacion]);
GO

-- Creating foreign key on [fkTour] in table 'Tou_Res'
ALTER TABLE [dbo].[Tou_Res]
ADD CONSTRAINT [FK_Tou_ResTour]
    FOREIGN KEY ([fkTour])
    REFERENCES [dbo].[Tour]
        ([IdTour])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Tou_ResTour'
CREATE INDEX [IX_FK_Tou_ResTour]
ON [dbo].[Tou_Res]
    ([fkTour]);
GO

-- Creating foreign key on [fkCargo] in table 'Empleado'
ALTER TABLE [dbo].[Empleado]
ADD CONSTRAINT [FK_CargoEmpleado]
    FOREIGN KEY ([fkCargo])
    REFERENCES [dbo].[Cargo]
        ([IdCargo])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CargoEmpleado'
CREATE INDEX [IX_FK_CargoEmpleado]
ON [dbo].[Empleado]
    ([fkCargo]);
GO

-- Creating foreign key on [fkEmpleado] in table 'Hab_Emp'
ALTER TABLE [dbo].[Hab_Emp]
ADD CONSTRAINT [FK_Hab_EmpEmpleado]
    FOREIGN KEY ([fkEmpleado])
    REFERENCES [dbo].[Empleado]
        ([IdEmpleado])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [fkCliente] in table 'Reservacion'
ALTER TABLE [dbo].[Reservacion]
ADD CONSTRAINT [FK_ReservacionCliente]
    FOREIGN KEY ([fkCliente])
    REFERENCES [dbo].[Cliente]
        ([IdCliente])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ReservacionCliente'
CREATE INDEX [IX_FK_ReservacionCliente]
ON [dbo].[Reservacion]
    ([fkCliente]);
GO

-- Creating foreign key on [fkReservacion] in table 'Hab_Res'
ALTER TABLE [dbo].[Hab_Res]
ADD CONSTRAINT [FK_Hab_ResReservacion]
    FOREIGN KEY ([fkReservacion])
    REFERENCES [dbo].[Reservacion]
        ([IdReservacion])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [fkReservacion] in table 'Mes_Res'
ALTER TABLE [dbo].[Mes_Res]
ADD CONSTRAINT [FK_ReservacionMes_Res]
    FOREIGN KEY ([fkReservacion])
    REFERENCES [dbo].[Reservacion]
        ([IdReservacion])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ReservacionMes_Res'
CREATE INDEX [IX_FK_ReservacionMes_Res]
ON [dbo].[Mes_Res]
    ([fkReservacion]);
GO

-- Creating foreign key on [fkMesa] in table 'Mes_Res'
ALTER TABLE [dbo].[Mes_Res]
ADD CONSTRAINT [FK_Mes_ResMesa]
    FOREIGN KEY ([fkMesa])
    REFERENCES [dbo].[Mesa]
        ([IdMesa])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Mes_ResMesa'
CREATE INDEX [IX_FK_Mes_ResMesa]
ON [dbo].[Mes_Res]
    ([fkMesa]);
GO

-- Creating foreign key on [fkRestaurante] in table 'Menu'
ALTER TABLE [dbo].[Menu]
ADD CONSTRAINT [FK_RestauranteMenu]
    FOREIGN KEY ([fkRestaurante])
    REFERENCES [dbo].[Restaurante]
        ([IdRestaurante])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RestauranteMenu'
CREATE INDEX [IX_FK_RestauranteMenu]
ON [dbo].[Menu]
    ([fkRestaurante]);
GO

-- Creating foreign key on [fkPlato] in table 'Mes_Res'
ALTER TABLE [dbo].[Mes_Res]
ADD CONSTRAINT [FK_PlatoMes_Res]
    FOREIGN KEY ([fkPlato])
    REFERENCES [dbo].[Plato]
        ([IdPlato])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PlatoMes_Res'
CREATE INDEX [IX_FK_PlatoMes_Res]
ON [dbo].[Mes_Res]
    ([fkPlato]);
GO

-- Creating foreign key on [fkPlato] in table 'RoomService'
ALTER TABLE [dbo].[RoomService]
ADD CONSTRAINT [FK_PlatoRoomService]
    FOREIGN KEY ([fkPlato])
    REFERENCES [dbo].[Plato]
        ([IdPlato])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PlatoRoomService'
CREATE INDEX [IX_FK_PlatoRoomService]
ON [dbo].[RoomService]
    ([fkPlato]);
GO

-- Creating foreign key on [fkReservacion] in table 'RoomService'
ALTER TABLE [dbo].[RoomService]
ADD CONSTRAINT [FK_RoomServiceReservacion]
    FOREIGN KEY ([fkReservacion])
    REFERENCES [dbo].[Reservacion]
        ([IdReservacion])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoomServiceReservacion'
CREATE INDEX [IX_FK_RoomServiceReservacion]
ON [dbo].[RoomService]
    ([fkReservacion]);
GO

-- Creating foreign key on [fkRestaurante] in table 'Mesa'
ALTER TABLE [dbo].[Mesa]
ADD CONSTRAINT [FK_RestauranteMesa]
    FOREIGN KEY ([fkRestaurante])
    REFERENCES [dbo].[Restaurante]
        ([IdRestaurante])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RestauranteMesa'
CREATE INDEX [IX_FK_RestauranteMesa]
ON [dbo].[Mesa]
    ([fkRestaurante]);
GO

-- Creating foreign key on [fkEmpleado] in table 'Usuario'
ALTER TABLE [dbo].[Usuario]
ADD CONSTRAINT [FK_UsuarioEmpleado]
    FOREIGN KEY ([fkEmpleado])
    REFERENCES [dbo].[Empleado]
        ([IdEmpleado])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UsuarioEmpleado'
CREATE INDEX [IX_FK_UsuarioEmpleado]
ON [dbo].[Usuario]
    ([fkEmpleado]);
GO

-- Creating foreign key on [fkTour] in table 'Horario'
ALTER TABLE [dbo].[Horario]
ADD CONSTRAINT [FK_HorarioTour]
    FOREIGN KEY ([fkTour])
    REFERENCES [dbo].[Tour]
        ([IdTour])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HorarioTour'
CREATE INDEX [IX_FK_HorarioTour]
ON [dbo].[Horario]
    ([fkTour]);
GO

-- Creating foreign key on [fkPiso], [fkHotel] in table 'Habitacion'
ALTER TABLE [dbo].[Habitacion]
ADD CONSTRAINT [FK_PisoHabitacion]
    FOREIGN KEY ([fkPiso], [fkHotel])
    REFERENCES [dbo].[Piso]
        ([IdPiso], [fkHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PisoHabitacion'
CREATE INDEX [IX_FK_PisoHabitacion]
ON [dbo].[Habitacion]
    ([fkPiso], [fkHotel]);
GO

-- Creating foreign key on [fkHabitacion], [fkPiso], [fkHotel] in table 'Hab_Res'
ALTER TABLE [dbo].[Hab_Res]
ADD CONSTRAINT [FK_Hab_ResHabitacion]
    FOREIGN KEY ([fkHabitacion], [fkPiso], [fkHotel])
    REFERENCES [dbo].[Habitacion]
        ([IdHabitacion], [fkPiso], [fkHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hab_ResHabitacion'
CREATE INDEX [IX_FK_Hab_ResHabitacion]
ON [dbo].[Hab_Res]
    ([fkHabitacion], [fkPiso], [fkHotel]);
GO

-- Creating foreign key on [fkHabitacion], [fkPiso], [fkHotel] in table 'Hab_Emp'
ALTER TABLE [dbo].[Hab_Emp]
ADD CONSTRAINT [FK_Hab_EmpHabitacion]
    FOREIGN KEY ([fkHabitacion], [fkPiso], [fkHotel])
    REFERENCES [dbo].[Habitacion]
        ([IdHabitacion], [fkPiso], [fkHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hab_EmpHabitacion'
CREATE INDEX [IX_FK_Hab_EmpHabitacion]
ON [dbo].[Hab_Emp]
    ([fkHabitacion], [fkPiso], [fkHotel]);
GO

-- Creating foreign key on [fkHotel] in table 'Propiedad'
ALTER TABLE [dbo].[Propiedad]
ADD CONSTRAINT [FK_PropiedadHotel]
    FOREIGN KEY ([fkHotel])
    REFERENCES [dbo].[Hotel]
        ([IdHotel])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PropiedadHotel'
CREATE INDEX [IX_FK_PropiedadHotel]
ON [dbo].[Propiedad]
    ([fkHotel]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------